import os
# def getFilename():
#
#     arr = []
#     for root,dirs,files in os.walk('/Users/zhangxing/PycharmProjects/pythonProject/1'):
#         for file in files:
#             if os.path.splitext(file)[1] == '.docx':
#                 # print(os.path.join(root,file))
#                 arr.append((os.path.join(root,file)).split(root+'/')[1])
#
#     # print(arr)
#
#     filname = arr[0].split('.')[0]
#     return filname
#     # print(filname)
#
#
# def getFiles():
#     # print(os.walk('/Users/zhangxing/PycharmProjects/pythonProject/1'))
#     print(os.listdir('/Users/zhangxing/PycharmProjects/pythonProject/1'))
#     arr = []
#     for root,dirs,files in os.walk('/Users/zhangxing/PycharmProjects/pythonProject/1'):
#         for file in files:
#             if os.path.splitext(file)[1] == '.docx':
#                 print(os.path.join(root,file))
#                 return os.path.join(root,file)


# getFilename()
# getFiles()

# 返回文件夹下的所有docx文件路径和文件名
class DocFiles():
    def __init__(self,path):
        self.path = path
        self.pathArr = []
        self.target_path = path
    def getPath(self):
        for file_path in os.listdir(self.path):
            self.pathArr.append({'path':self.path + '/' + file_path,'name':file_path.split('.')[0]})
        return self.pathArr

    def targetPath(self):
        return self.target_path